home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
clipper
/
nfsrc21.zip
/
_WHEREIS.ASM
next >
Wrap
Assembly Source File
|
1991-08-15
|
24KB
|
535 lines
; File......: _WHEREIS.ASM
; Author....: Steve Larsen
; CIS ID....: 76370,1532
; Date......: $Date: 15 Aug 1991 23:08:08 $
; Revision..: $Revision: 1.1 $
; Log file..: $Logfile: E:/nanfor/src/_whereis.asv $
;
; This is an original work by K. Stephan Larsen and is placed in
; the public domain.
;
; Modification history:
; ---------------------
;
; $Log: E:/nanfor/src/_whereis.asv $
;
; Rev 1.1 15 Aug 1991 23:08:08 GLENN
; Forest Belt proofread/edited/cleaned up doc
;
; Rev 1.0 07 Jun 1991 21:56:10 GLENN
; Initial revision.
;
;
PUBLIC __ft_where, __ft_tree
EXTRN __storc:far, __retni:far, __parinfo:far, __parclen:far
EXTRN __parc:far, __xfree:far, __xalloc:far
;
; Create offsets to mvars and DTA buffering area. The segment "DATASG"
; is culled from the free pool, therefore goes away when these functions
; are not active. All mvar initialization must take place at
; runtime, rather than compiletime.
;
DATASG SEGMENT 'DATA'
filename db 13 dup(?), ? ; passed filename
olddrive db ? ; our current drive
eop dw ? ; pointer to end-of-path string
count dw ? ; current element
is_array dw ? ; parm No., if array was passed
a_count db ? ; array length
dirname db 4 dup(?) ; '*.*' mask for directories
dir_nest db ? ; directory level
dta_ptr db ? ; pointer to current dir dta
path db ?, 20 * 14 dup(?) ; buffer for current path
dta_buff db 20 * 43 dup(?) ; DTA for directories
std_dta db 128 DUP(?) ; DTA for files
dta_file_offset equ 1Eh ; offset to filename within DTA
dta_attr_offset equ 15h ; offset to file type within DTA
dta_len equ 43 ; length of DTA that we're interested in
segsize equ $ - filename ; amount of free pool memory req'd
DATASG ends
; local vars go on stack, this is necessary since we cannot access data
; within our data seg until it is allocated
oldsegloc equ <ss:[bp-02h]> ; Clipper's DS
newsegloc equ <ss:[bp-04h]> ; our data area's Segment
newoffset equ <ss:[bp-06h]> ; our data area's Offset
newsegment equ <ss:[bp-08h]> ; after adjusting to the first
; paragraph within our data
; area, this is the "Segment"
; value of our data seg
_NANFOR segment word public 'CODE'
ASSUME CS:_NANFOR
__ft_where PROC FAR
push ds ; save Clipper's environment
push es
push di
push si
push bp
mov bp, sp
sub sp, 08h ; make room on stack for locals
w_1: call GetParms ; fetch parms, set up our data seg
mov ds, newsegloc ; now point DS to our data seg
assume ds:datasg
mov ax, offset path ; point to the current path (starts
inc ax
mov eop, ax ; first EOP is 1 past "\"
call HuntMDown ; look for files in root directory
w_2: call FirstDir ; find first subdirectory
jc w_4 ; no subdir, set DTA back 1 dir lvl
w_3: call IsParent ; found dir, check for DOS signature
jc w_5 ; nope, go to next directory
call HuntMDown ; OK, now look for files in directory
w_6: call UpDir ; move DTA up a level for subdirs
jmp w_2 ; and do it all over again
w_4: call DownDir ; go back one level, look for another
w_5: call NextDir ; subdir. If CY returns set, no more
jc w_4 ; subdirs, back up another level...
jmp w_3 ; subdir was found, continue
HuntMDown: ; requires EOP in BL, DTA set
call FindFile ; set up to look for files
; DI points to EOP
call FindFirst ; find first matching file in dir
h_1: jc h_3 ; if not found, return to calling routine
inc count ; file was found, increment count
mov si, offset std_dta + dta_file_offset ; and point SI to
; file's name within current DTA
call File2Path ; add filename to end of current path
call Save2Array ; copy full path/filename to array
h_2: call FindNext ; set up DOS to find next file/dir
jmp h_1
h_3: clc ; clear carry if set by parent dir
retn ; endp HuntMDown
FirstDir: ; locates first subdir in a level
call FindDir ; set up DOS search parms for a dir
call MakePath ; create the path
mov si, offset dirname ; add the "*.*" to the path
call File2Path
mov cx, 10h ; directory attribute to search for
call FindFirst ; go do it
retn
IsParent: ; checks for "." or ".."
mov ah, 2Fh ; fetch current DTA in ES:BX
int 21h
mov si, bx ; point SI to DTA
add si, dta_file_offset ; point SI to dirname within DTA
lodsb ; fetch first char of dirname
clc
cmp al, '.' ; check if parent directory
jne ip_1 ; yep, this is a legit directory
stc ; nope, set CY to inform calling
ip_1: retn ; routine
NextDir: ; finds next subdir in current level
call FindDir ; select directory DTA
mov cx, 10h ; directory attribute to look for
call FindNext ; go a'lookin
retn
FindDir: ; sets DTA to current directory DTA
mov dx, offset dta_buff ; returns with carry set upon failure
xor cx ,cx
mov cl, dta_ptr ; get current dir level, test for
cmp cx, 0 ; bottom
je fd_1 ;
fd_2: add dx, dta_len ; if not, increment DX to proper level
loop fd_2
fd_1: mov ah, 1Ah ; set DTA
int 21h
retn
FindFile: ; sets DTA to file DTA
mov dx, offset std_dta ; point to file DTA
mov ah, 1Ah
int 21h ; set it
call MakePath ; construct current path
mov si, offset filename ; add the filespec
call File2Path
xor cx, cx ; set attribute for normal files
ff_1: retn
UpDir:
inc dta_ptr ; inc the nest and segment pointers
inc dir_nest
retn
DownDir: ; clears last DTA for reuse
mov di, offset dta_buff + dta_file_offset ; point DI to last
xor cx, cx ; dirname searched by multiplying
mov cl, dta_ptr ; length of DTA times No of DTA's